package dk.sensobyg.meta;

import java.net.URL;
import java.util.List;
import java.util.LinkedList;

public class SimpleSensorDatabase implements SensorDatabase {

	private List<SensorDescription> sensors;
	private List<SensorType> types;
	
	public SimpleSensorDatabase() {
		sensors = new LinkedList<SensorDescription>();
		types = new LinkedList<SensorType>();
	}
	
	public SensorDescription allocateSensor(long typeid, URL url) {
		SensorDescription s = new SensorDescription(sensors.size()+1, typeid, url);
		sensors.add(s);
		return s;
	}

	public SensorType allocateType(String name, String description) {
		SensorType t = new SensorType(types.size()+1, name, description);
		types.add(t);
		return t;
	}

	public SensorDescription getSensor(long sensorid) {
		return sensors.get((int)sensorid);
	}

	public SensorType getType(long typeid) {
		return types.get((int)typeid);
	}

}

